package net.fivegoods.entity.impl.slim3;

//@javax.annotation.Generated(value = { "slim3-gen", "@VERSION@" }, date = "2011-03-20 23:13:45")
/** */
public final class MissionExecutionModelMeta extends org.slim3.datastore.ModelMeta<net.fivegoods.entity.impl.slim3.MissionExecutionModel> {

    /** */
    public final org.slim3.datastore.CoreAttributeMeta<net.fivegoods.entity.impl.slim3.MissionExecutionModel, com.google.appengine.api.datastore.Key> key = new org.slim3.datastore.CoreAttributeMeta<net.fivegoods.entity.impl.slim3.MissionExecutionModel, com.google.appengine.api.datastore.Key>(this, "__key__", "key", com.google.appengine.api.datastore.Key.class);

    /** */
    public final org.slim3.datastore.ModelRefAttributeMeta<net.fivegoods.entity.impl.slim3.MissionExecutionModel, org.slim3.datastore.ModelRef<net.fivegoods.entity.impl.slim3.MissionModel>, net.fivegoods.entity.impl.slim3.MissionModel> missionRef = new org.slim3.datastore.ModelRefAttributeMeta<net.fivegoods.entity.impl.slim3.MissionExecutionModel, org.slim3.datastore.ModelRef<net.fivegoods.entity.impl.slim3.MissionModel>, net.fivegoods.entity.impl.slim3.MissionModel>(this, "missionRef", "missionRef", org.slim3.datastore.ModelRef.class, net.fivegoods.entity.impl.slim3.MissionModel.class);

    /** */
    public final org.slim3.datastore.CoreAttributeMeta<net.fivegoods.entity.impl.slim3.MissionExecutionModel, java.lang.Integer> state = new org.slim3.datastore.CoreAttributeMeta<net.fivegoods.entity.impl.slim3.MissionExecutionModel, java.lang.Integer>(this, "state", "state", int.class);

    /** */
    public final org.slim3.datastore.ModelRefAttributeMeta<net.fivegoods.entity.impl.slim3.MissionExecutionModel, org.slim3.datastore.ModelRef<net.fivegoods.entity.impl.slim3.VolunteerModel>, net.fivegoods.entity.impl.slim3.VolunteerModel> volunteerRef = new org.slim3.datastore.ModelRefAttributeMeta<net.fivegoods.entity.impl.slim3.MissionExecutionModel, org.slim3.datastore.ModelRef<net.fivegoods.entity.impl.slim3.VolunteerModel>, net.fivegoods.entity.impl.slim3.VolunteerModel>(this, "volunteerRef", "volunteerRef", org.slim3.datastore.ModelRef.class, net.fivegoods.entity.impl.slim3.VolunteerModel.class);

    private static final MissionExecutionModelMeta slim3_singleton = new MissionExecutionModelMeta();

    /**
     * @return the singleton
     */
    public static MissionExecutionModelMeta get() {
       return slim3_singleton;
    }

    /** */
    public MissionExecutionModelMeta() {
        super("MissionExecutionModel", net.fivegoods.entity.impl.slim3.MissionExecutionModel.class);
    }

    @Override
    public net.fivegoods.entity.impl.slim3.MissionExecutionModel entityToModel(com.google.appengine.api.datastore.Entity entity) {
        net.fivegoods.entity.impl.slim3.MissionExecutionModel model = new net.fivegoods.entity.impl.slim3.MissionExecutionModel();
        model.setKey(entity.getKey());
        if (model.getMissionRef() == null) {
            throw new NullPointerException("The property(missionRef) is null.");
        }
        model.getMissionRef().setKey((com.google.appengine.api.datastore.Key) entity.getProperty("missionRef"));
        model.setState(longToPrimitiveInt((java.lang.Long) entity.getProperty("state")));
        if (model.getVolunteerRef() == null) {
            throw new NullPointerException("The property(volunteerRef) is null.");
        }
        model.getVolunteerRef().setKey((com.google.appengine.api.datastore.Key) entity.getProperty("volunteerRef"));
        return model;
    }

    @Override
    public com.google.appengine.api.datastore.Entity modelToEntity(java.lang.Object model) {
        net.fivegoods.entity.impl.slim3.MissionExecutionModel m = (net.fivegoods.entity.impl.slim3.MissionExecutionModel) model;
        com.google.appengine.api.datastore.Entity entity = null;
        if (m.getKey() != null) {
            entity = new com.google.appengine.api.datastore.Entity(m.getKey());
        } else {
            entity = new com.google.appengine.api.datastore.Entity(kind);
        }
        if (m.getMissionRef() == null) {
            throw new NullPointerException("The property(missionRef) must not be null.");
        }
        entity.setProperty("missionRef", m.getMissionRef().getKey());
        entity.setProperty("state", m.getState());
        if (m.getVolunteerRef() == null) {
            throw new NullPointerException("The property(volunteerRef) must not be null.");
        }
        entity.setProperty("volunteerRef", m.getVolunteerRef().getKey());
        return entity;
    }

    @Override
    protected com.google.appengine.api.datastore.Key getKey(Object model) {
        net.fivegoods.entity.impl.slim3.MissionExecutionModel m = (net.fivegoods.entity.impl.slim3.MissionExecutionModel) model;
        return m.getKey();
    }

    @Override
    protected void setKey(Object model, com.google.appengine.api.datastore.Key key) {
        validateKey(key);
        net.fivegoods.entity.impl.slim3.MissionExecutionModel m = (net.fivegoods.entity.impl.slim3.MissionExecutionModel) model;
        m.setKey(key);
    }

    @Override
    protected long getVersion(Object model) {
        throw new IllegalStateException("The version property of the model(net.fivegoods.entity.impl.slim3.MissionExecutionModel) is not defined.");
    }

    @Override
    protected void assignKeyToModelRefIfNecessary(com.google.appengine.api.datastore.AsyncDatastoreService ds, java.lang.Object model) {
        net.fivegoods.entity.impl.slim3.MissionExecutionModel m = (net.fivegoods.entity.impl.slim3.MissionExecutionModel) model;
        if (m.getMissionRef() == null) {
            throw new NullPointerException("The property(missionRef) must not be null.");
        }
        m.getMissionRef().assignKeyIfNecessary(ds);
        if (m.getVolunteerRef() == null) {
            throw new NullPointerException("The property(volunteerRef) must not be null.");
        }
        m.getVolunteerRef().assignKeyIfNecessary(ds);
    }

    @Override
    protected void incrementVersion(Object model) {
    }

    @Override
    protected void prePut(Object model) {
    }

    @Override
    public String getSchemaVersionName() {
        return "slim3.schemaVersion";
    }

    @Override
    public String getClassHierarchyListName() {
        return "slim3.classHierarchyList";
    }

    @Override
    protected boolean isCipherProperty(String propertyName) {
        return false;
    }

    @Override
    protected void modelToJson(org.slim3.datastore.json.JsonWriter writer, java.lang.Object model, int maxDepth, int currentDepth) {
        net.fivegoods.entity.impl.slim3.MissionExecutionModel m = (net.fivegoods.entity.impl.slim3.MissionExecutionModel) model;
        writer.beginObject();
        org.slim3.datastore.json.JsonCoder encoder = null;
        if(m.getKey() != null){
            writer.setNextPropertyName("key");
            encoder = new org.slim3.datastore.json.Default();
            encoder.encode(writer, m.getKey());
        }
        if(m.getMissionRef() != null && m.getMissionRef().getKey() != null){
            writer.setNextPropertyName("missionRef");
            encoder = new org.slim3.datastore.json.Default();
            encoder.encode(writer, m.getMissionRef(), maxDepth, currentDepth);
        }
        writer.setNextPropertyName("state");
        encoder = new org.slim3.datastore.json.Default();
        encoder.encode(writer, m.getState());
        if(m.getVolunteerRef() != null && m.getVolunteerRef().getKey() != null){
            writer.setNextPropertyName("volunteerRef");
            encoder = new org.slim3.datastore.json.Default();
            encoder.encode(writer, m.getVolunteerRef(), maxDepth, currentDepth);
        }
        writer.endObject();
    }

    @Override
    protected net.fivegoods.entity.impl.slim3.MissionExecutionModel jsonToModel(org.slim3.datastore.json.JsonRootReader rootReader, int maxDepth, int currentDepth) {
        net.fivegoods.entity.impl.slim3.MissionExecutionModel m = new net.fivegoods.entity.impl.slim3.MissionExecutionModel();
        org.slim3.datastore.json.JsonReader reader = null;
        org.slim3.datastore.json.JsonCoder decoder = null;
        reader = rootReader.newObjectReader("key");
        decoder = new org.slim3.datastore.json.Default();
        m.setKey(decoder.decode(reader, m.getKey()));
        reader = rootReader.newObjectReader("missionRef");
        decoder = new org.slim3.datastore.json.Default();
        decoder.decode(reader, m.getMissionRef(), maxDepth, currentDepth);
        reader = rootReader.newObjectReader("state");
        decoder = new org.slim3.datastore.json.Default();
        m.setState(decoder.decode(reader, m.getState()));
        reader = rootReader.newObjectReader("volunteerRef");
        decoder = new org.slim3.datastore.json.Default();
        decoder.decode(reader, m.getVolunteerRef(), maxDepth, currentDepth);
        return m;
    }
}